#include <iostream>
using namespace std;

typedef struct {
  int w,p,l,r,used;
}HfNode,*HfNodePtr;

int getMin(HfNodePtr head,int m){
  int min = 0x7FFFFFFF;
  int k;
  for(int i = 0;i < m;i++){
    if(min > head[i].w && head[i].used != 1){
      min = head[i].w;
      k = i;
    }
  }
  return k;
}

typedef struct {
  char *data;
  int length;
}HfCode, *HfCodePtr;

HfCodePtr CreateHuffmanCode(HfNodePtr head,int n){
  HfCodePtr p = new HfCode[n];
  for(int i = 0;i < n;i++){
    int j = i;
    p[i].data = new char[10];
    p[i].length = 0;
    while(head[j].p != -1){
      if(j == head[head[j].p].l){
        p[i].data[p[i].length++] = '0';
      } else {
        p[i].data[p[i].length++] = '1';
      }
      j = head[j].p;
    }
  }
  return p;
}

void CreateHuffmanTree(HfNodePtr& head,int n){
  head = new HfNode[2*n-1];
  int m;
  for (int i = 0; i < n; i++) {
    cin >> m;
    head[i].w = m;
    head[i].p = head[i].l = head[i].r = -1;
    head[i].used = 0;
  }

  int minl,minr;
  for(int i = n;i < 2*n-1;i++){
    minl = getMin(head,i);
    head[minl].used = 1;
    minr = getMin(head,i);
    head[minr].used = 1;
    
    head[minl].p = head[minr].p = i;

    head[i].w = head[minl].w + head[minr].w;
    head[i].p = -1;
    head[i].l = minl;
    head[i].r = minr;
    head[i].used = 0;
  }
}

void OutputHfCode(HfCodePtr p,int n){
  for (size_t i = 0; i < n; i++) {
    for(int j = p[i].length-1;j >= 0;j--){
      cout << p[i].data[j];
    }
    cout << endl;
  }
}


int main(){
  int n;
  cin >> n;
  HfNodePtr tree;
  CreateHuffmanTree(tree,n);
  for(int i = 0;i < 2*n-1;i++){
    cout << tree[i].w << " " << tree[i].p << " " << tree[i].l << " " << tree[i].r << " " << tree[i].used << endl;
  }
  HfCodePtr p = CreateHuffmanCode(tree,n);
  OutputHfCode(p,n);
}
